﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using SVC.client;
namespace UI.Forms
{
    public partial class Select_BC : DevExpress.XtraEditors.XtraForm
    {
        public delegate void DoAction(List<Cards_Select> cs);//如果有参数的话，定义参数 
        public DoAction FatherRefresh;
        BindingList<Cards_Select> casl;
        private string kcid = "";
        /// <summary>
        /// 仓库ID
        /// </summary>
        /// <param name="kcid"></param>
        public Select_BC(string _kcid)
        {
            InitializeComponent();
            kcid = _kcid;
        }

        private void Select_BC_Load(object sender, EventArgs e)
        {
            bind();
        }

        private void bind()
        {
            rle_GoodCode.DataSource = my.bw.View_Goods_Lite_List("",my.ACID);
            rle_GoodCode.DisplayMember = "GoodsName";
            rle_GoodCode.ValueMember = "GoodsCode";
            BindingList<SVC.client.Cards> cas = my.bw.Card_Get(null, kcid, "", 0, my.ACID);
            casl = new BindingList<Cards_Select>();
            foreach (SVC.client.Cards card in cas)
            {
                if (card.ClientID!=null)
                {
                    Cards_Select cs = new Cards_Select();
                    cs.cno = card.cno;
                    cs.GoodsCode = card.GoodsCode;
                    cs.indate = card.indate;
                    cs.jg = card.jg;
                    cs.Remarks = card.Remarks;
                    cs.Selected = false;
                    cs.state = card.state;
                    cs.WarehouseID = card.WarehouseID;
                    casl.Add(cs);
                }

            }
            gridControl1.DataSource = casl;
        }

        private void btn_sx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            bind();
        }

        private void btn_OK_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FatherRefresh(casl.Where(p=>p.Selected).ToList());
            this.Close();
        }


    }
}